package com.example.demo.exception;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

@Controller
public class ExController {

    @ResponseBody
    @GetMapping("ex1")
    public String ex1(){
        if( 1 == 1){
            throw new IllegalArgumentException("xx");
        }
        return "ok";
    }

    @ResponseBody
    @GetMapping("ex2")
    public String ex2(){
        if( 1 == 1){
            throw new MyException("xx");
        }
        return "ok";
    }

    @ResponseStatus(code = HttpStatus.CONFLICT,reason = "错了错了错了")
    @GetMapping("ex3")
    public String ex3(){
        return "ok";
    }
}
